package cn.e3mall.item.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.e3mall.item.pojo.Item;
import cn.e3mall.pojo.TbItem;
import cn.e3mall.pojo.TbItemDesc;
import cn.e3mall.service.ItemService;
/*
 * 商品详情页面展示
 */
@Controller
public class ItemController {
	
	@Autowired
	private ItemService itemService;


	@RequestMapping("/item/{itemId}")
	public String showItemInfo(
			@PathVariable Long itemId,ModelMap m){
		TbItem tbItem = itemService.getItemById(itemId);
		Item item=new Item(tbItem);
		//取商品描述
		TbItemDesc itemDesc= itemService.getItemDescById(itemId);
		//把信息传递页面
			m.addAttribute("item", item);
			m.addAttribute("itemDesc", itemDesc);
		return "item";
	}

}
